/*package com.health.db.dao.user.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.user.IUserLISTDao;
import com.health.db.mapper.UserLISTMapper;
import com.health.db.model.UserLIST;
import com.health.db.model.UserLISTExt;
import com.health.redis.RedisConstants;


*//**
 * 用户表
 * 缓存适用
 * @author YC
 *
 *//*
public class UserLISTDaoImpl  extends ServiceInterface implements IUserLISTDao{

    UserLISTMapper userLISTMapper;

    String selectByUserNo=":userNo:";
    String selectByStuffNo =":StuffNo:";
    String selectByUserId=":userId:";
    String selectByWXOpenId=":WXOpenId:";
    *//**
     * method Order 1
     *//*
    @Override
    public UserLIST selectByUserId(Long userId) {
        // TODO Auto-generated method stub
        getRedisOperatiorLogic();
        String key =RedisConstants.UserLISTMapper+selectByUserId+userId;
        
        Object object=null;
        UserLIST userLIST = null;
    
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            //get data from redis
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	if (!object.equals("")) {
        		  userLIST =  (UserLIST) object;
			}
         }else{
          UserLISTExt example=new UserLISTExt();
         
          example.setUserid(userId);
        
          userLIST=userLISTMapper.selectByUserId(userId);
          if(redisOperatiorLogic.isJedisIsConnected())
            {redisOperatiorLogic.setEx(key, userLIST,  getOrderRedisGroupNo("1"));}
         }
    
        if (null==userLIST) {
            return null;
        }
        return userLIST;
    }


    @Override
    public int updateByPrimaryKey(UserLIST userLIST) {
        // TODO Auto-generated method stub
        int result=-1;
        result=userLISTMapper.updateByPrimaryKey(userLIST);
        deleteCach(userLIST.getUserid());
        
        if (StringUtils.isNotEmpty( userLIST.getWxopenid())) {
        	deleteWXListCach(userLIST.getWxopenid());
		}
        return result;
    }


    @Override
    public int insertUser(UserLIST userLIST) {
        // TODO Auto-generated method stub
        int result=-1;
    
        result=userLISTMapper.insert(userLIST);
        deleteCach(userLIST.getUserid());
        return result;
    }

    @Override
    public int updatePassword(UserLIST userLIST) {
        // TODO Auto-generated method stub
        int result=-1;
        result=userLISTMapper.updatePassword(userLIST);
        deleteCach(userLIST.getUserid());
        return result;
    }

    public UserLISTMapper getUserLISTMapper() {
        return userLISTMapper;
    }

    public void setUserLISTMapper(UserLISTMapper userLISTMapper) {
        this.userLISTMapper = userLISTMapper;
    }

    @Override
    public UserLIST selectByUserNo(String userNo) {

        // TODO Auto-generated method stub
        getRedisOperatiorLogic();
        String key =RedisConstants.UserLISTMapper+selectByUserNo+userNo;
        
        Object object=null;
        UserLIST userLIST = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	if (!object.equals("")) {
        		 userLIST =  (UserLIST) object;
			}
         }else{
          userLIST=userLISTMapper.selectByUserNo(userNo);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, userLIST,  getOrderRedisGroupNo("1"));
             }
         }
               
        if (null==userLIST) {
            return null;
        }
        return userLIST;
    }

    @Override
    public int updateLoginInfo(UserLIST userLIST) {
        
        userLISTMapper.updateLoginInfo(userLIST);
        deleteCach(userLIST.getUserid());
        return  1;
    }

    @Override
    public List<UserLIST> selectByWXOpenId(String wxopenid) {
        // TODO Auto-generated method stub
        getRedisOperatiorLogic();
        String key =RedisConstants.UserLISTMapper+selectByWXOpenId+wxopenid;
        
        Object object=null;
        List<UserLIST> list = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	 if (!object.equals("")) {
        		 list = ( List<UserLIST>) object;
			}
         }else{
        	 list=userLISTMapper.selectByWxOpenId(wxopenid);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
             }
         }
        return list;
    }
    
   //删除缓存
   private void deleteCach( Long userid){
	   
	   getRedisOperatiorLogic();
	   if(redisOperatiorLogic.isJedisIsConnected())
       {
		   String key =RedisConstants.UserLISTMapper+selectByUserId+userid;
		   
		   UserLIST userList = selectByUserId(userid);
		   if(null!=userList){
			   redisOperatiorLogic.deleteObject(key, getOrderRedisGroupNo("1"));
			   redisOperatiorLogic.deleteObject(RedisConstants.UserLISTMapper+selectByUserNo+userList.getUserNo(), getOrderRedisGroupNo("1"));
			   
			   if (null!=userList.getTypeid()&&userList.getTypeid().intValue()==3) {
				   redisOperatiorLogic.deleteObject(RedisConstants.StuffListMapper+selectByStuffNo+userList.getUserNo().replace("#", ""), getOrderRedisGroupNo("1"));
				
			   }
			   if (null!=userList.getTypeid()&&userList.getTypeid().intValue()==2) {
				   redisOperatiorLogic.deleteObject(RedisConstants.StuffListMapper+selectByStuffNo+userList.getUserNo().replace("#", ""), getOrderRedisGroupNo("1"));
				
			   }
	       }
	   }
	   
   }
   
   
   //删除缓存
   private void deleteWXListCach( String wxopenid){
	   
	   getRedisOperatiorLogic();
	   if(redisOperatiorLogic.isJedisIsConnected())
       {
		  redisOperatiorLogic.deleteObject(RedisConstants.UserLISTMapper+selectByWXOpenId+wxopenid, getOrderRedisGroupNo("1"));
	   }
	   
   }


 private String selectByBusinessCode = ":bCode:";
   
@Override
public List<UserLIST> selectByBusinessCode(String businessCode) {
	// TODO Auto-generated method stub
	  // TODO Auto-generated method stub
    getRedisOperatiorLogic();
    String key =RedisConstants.UserLISTMapper+selectByBusinessCode+businessCode;
    
    Object object=null;
    List<UserLIST> list = null;
  
    if(redisOperatiorLogic.isJedisIsConnected())
    {    
        object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
     }
     if(null!=object){
    	 if (!object.equals("")) {
    		 list = ( List<UserLIST>) object;
		}
     }else{
    	 list=userLISTMapper.selectByBusinessCode(businessCode);
      if(redisOperatiorLogic.isJedisIsConnected())
        {
            redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
         }
     }
    return list;
	
}

    @Override
    public int updateUserOpenId(UserLIST userLIST) {
        return 0;
    }

}
*/